<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="javax.servlet.http.Cookie" %>    
<%@ page import="java.net.*" %>  
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改</title>
<link type="text/css" rel="stylesheet" href="<c:url value='/css/style.css'/>" />
<link rel="stylesheet" type="text/css" href="<c:url value='/css/common.css'/>">
<script type="text/javascript" src="<c:url value='/js/jquery-1.8.3.min.js'/>"></script>
</head>
<body>
	<div class="m-right">
		<div class="right-nav">
			<ul>
				<li><img src="<c:url value='/images/home.png'/>"></li>
				<li style="margin-left: 25px;">您当前的位置：</li>
				<li><a href="#">修改</a></li>
				<li>&gt;</li>
				<li><a href="#">用户信息修改</a></li>
			</ul>
		</div>
		<div class="main">
			<div>
				<span><font color="red">${requestScope.msg }</font></span>
				<form class="modfiy_user" action="<c:url value='/user/${sessionScope.user.id }'/>" method="post">
					原密码：<input class="oldPwd" type="password" name="oldPwd" value="123"/><br>
					新密码：<input class="password" type="password" name="password"/><br>
					确认密码：<input class="repeatPwd" type="password" name="repeatPwd"/><br>
					<input type="submit" value="提交">
				</form>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		//异步校验原密码是否正确
		$(".oldPwd").change(function() {
			var pwd = $(".oldPwd").val();
			$.ajax({
				   type: "POST",
				   url: "<c:url value='/user/check'/>",
				   data: "password=" + pwd,
				   success: function(data){
					   if(data.status == 500) {
						   alert(data.msg);
					   } else if(data.status == 400) {
						   location.href= data.msg;
					   }
				   }
				});
		});	
	});
</script>
</html>
